package com.roubsite.admin.dao.rsOrgan;

import java.sql.Types;
import java.util.List;

import com.roubsite.admin.bean.RsOrgan;
import com.roubsite.database.bean.Record;
import com.roubsite.database.dao.DataSet;
import com.roubsite.database.dao.EntityDao;

public class RsOrganDao extends EntityDao implements IRsOrganDao {

	@Override
	public DataSet getInfoById(String id) {
		DataSet ds = this.queryBean("SELECT * FROM RS_ORGAN WHERE ORGAN_ID =?", new String[] { id },
				new int[] { Types.VARCHAR }, false, 0, 0, RsOrgan.class);
		return ds;
	}

	@Override
	public DataSet queryd(Record record, int start, int rows) {
		return this.queryBean(record.toBean(RsOrgan.class), null, true, start, rows);
	}

	@Override
	public int saveData(Record record, Class<?> bean) {
		return this.save(record, bean);
	}

	@Override
	public int del(List ids) throws Exception {
		String tableName = "RS_ORGAN";
		String keyField = "ORGAN_ID";
		StringBuffer delSql = new StringBuffer("DELETE FROM " + tableName + " WHERE " + keyField + " IN (");
		for (int i = 0; i < ids.size(); i++) {
			delSql.append("'");
			delSql.append(ids.get(i));
			delSql.append("',");
		}
		String sql = delSql.substring(0, delSql.length() - 1);
		sql = sql + ")";

		return this.excute(sql, new Object[] {}, new int[] {});
	}

	@Override
	public List queryAll() {
		return this.query("SELECT * FROM RS_ORGAN", null, null);
	}

}
